#include <iostream>  

using namespace std;  
  
double power (double num,int index)
{
    if (index == 0 && num!=0) 
    {  
        return 1;  
    }  
    else if (index == 0 && num==0) 
    {  
        return 0;  
    }  
    else if(index < 0 && num!=0)
    {
        return power(1/num,-index);
    }
    double x = power(num,index/2);
    if(index&1==1)
    {
        return x*x*num;
    }
    else
    {
        return x*x;
    }
}

int main() 
{  
    double num;  
    int index;  

    std::cout << "请输入底数：";  
    std::cin >> num;  
      
    std::cout << "请输入指数：";  
    std::cin >> index;  

    if (index < 0 && num==0) 
    {  
        std::cout << "结果为：不存在" <<endl;
    } 
    else
    {
        std::cout << "结果为：" << power(num,index) <<endl;
    } 
    
}  